//
//  RiLiCell.m
//  XDBaseFrameWork
//
//  Created by XD-XY on 10/28/14.
//  Copyright (c) 2014 XD-XY. All rights reserved.
//

#import "RiLiCell.h"

@implementation RiLiCell

- (id)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        // Initialization code
        [self makeViews];
    }
    return self;
}

-(void)makeViews
{
    self.backgroundColor = [UIColor whiteColor];
    
    // 日期
    self.dayLB = [UILabel initLabelText:@"" andRect:CGRectMake(0,0,UI_SCREEN_WIDTH/5.0f,29) andBackGroudColor:[UIColor whiteColor] andTextFont:[UIFont systemFontOfSize:15] andTextColor:UIColorFromRGB(0x676767) andTextAlignment:NSTextAlignmentCenter];
    [self.contentView addSubview:_dayLB];
    
    // 上午按钮
    self.amBtn = [UIButton initButton:CGRectMake(0,height_y(_dayLB),UI_SCREEN_WIDTH/5.0f-0.5,42.5) btnNorImage:LOADIMAGE(@"etime_nor@2x") btnDisableBtn:LOADIMAGE(@"etime_sel@2x") btnTitle:@"" titleNorColor:UIColorFromRGB(0x616161) titleSelectColor:UIColorFromRGB(0xf1f1f1) titleFont:[UIFont systemFontOfSize:12]];
    [self.amBtn setTitle:@"上午未约" forState:UIControlStateNormal];
    [self.amBtn setTitle:@"上午已定" forState:UIControlStateDisabled];
    
    _amBtn.tag = 1001;
    [self.contentView addSubview:_amBtn];
    
    // 下午按钮
    self.pmBtn = [UIButton initButton:CGRectMake(0,height_y(_amBtn)+1,UI_SCREEN_WIDTH/5.0f-0.5,42.5) btnNorImage:LOADIMAGE(@"etime_nor@2x") btnDisableBtn:LOADIMAGE(@"etime_sel@2x") btnTitle:@"" titleNorColor:UIColorFromRGB(0x616161) titleSelectColor:UIColorFromRGB(0xf1f1f1) titleFont:[UIFont systemFontOfSize:12]];
    [self.contentView addSubview:_pmBtn];
    [self.pmBtn setTitle:@"下午未约" forState:UIControlStateNormal];
    [self.pmBtn setTitle:@"下午已定" forState:UIControlStateDisabled];
    
    _pmBtn.tag = 1002;
    
    
    // 监听点击事件
    [_amBtn addTarget:self action:@selector(chooseTime:) forControlEvents:UIControlEventTouchUpInside];
    [_pmBtn addTarget:self action:@selector(chooseTime:) forControlEvents:UIControlEventTouchUpInside];
}

-(void)chooseTime:(UIButton *)sender
{
    if(sender.tag == 1001){
        [_delegate chooseTheEmplTime:self.timeSting andAmOrPm:@"AM" name:@"上午"];
    }else{
        [_delegate chooseTheEmplTime:self.timeSting andAmOrPm:@"PM" name:@"下午"];

    }
}


/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect
{
    // Drawing code
}
*/

@end
